<?php
declare (strict_types = 1);

namespace app\shop\controller;

use think\annotation\Route;
use think\annotation\route\Group;
use think\annotation\route\Middleware;
use app\common\service\OrderService\OrderCheckService;
use app\BaseShopController;
use think\Request;

/**
 * @Group("Order")
 * @Middleware({shopMiddileware::class})
 */
class Order extends BaseShopController
{
    
    /**
     * 获取订单列表分页
     * @Route("getListByPage",method="GET")
     * @return string
     */
    public function getListByPage() {        
//        if(isset($this->_data['cb_id'])&& is_array($this->_data['cb_id'])&&$this->_master_user['cb_id']==0&&$this->_data['cb_id'][0]){
//            $this->_all_data['cb_id']=$this->_data['cb_id'];
//        }elseif($this->_master_user['cb_id']>0){
//            $this->_all_data['cb_id']=[$this->_master_user['cb_id']];
//        }else{
//            unset($this->_all_data['cb_id']);
//        }
        $param= $this->_data;
        $param['cid']= $this->_master_user['cid'];
        if($this->_master_user['cb_id']>0){
            $param['cb_id']= $this->_master_user['cb_id'];
        }
        $result = callApi(OrderCheckService::class, 'orderList',$param);
        return apiResponse($result);
    }
    
    /**
     * 获取订单列表分页
     * @Route("getOrderStatus",method="GET")
     * @return string
     */
    public function getOrderStatus() { 
        $result = callApi(OrderCheckService::class, 'getOrderStatus',$this->_all_data);
        return apiResponse($result);
    }
    
    /**
     * 获取订单详情
     * @Route("getOrderDetail/:sn",method="GET")
     * @return string
     */
    public function getOrderDetail($sn) { 
        $result = callApi(OrderCheckService::class, 'orderDetail',$this->_all_data);
        return apiResponse($result);
    }
    
}
